<%@page import="vo.MemberVo"%>
<%@page import="dao.MemberDao"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%
	request.setCharacterEncoding("utf-8");


	System.out.println("login_chexk___");
	
	String login = request.getParameter("login");

	

	if (login.equals("on")) {
		String id = request.getParameter("id");
		String c_pwd = request.getParameter("pwd");
		MemberVo mvo = MemberDao.getDao().informMemberId(id);
		
		//아이디비존재
		if (mvo == null) {
			out.println("[{'result':'no_id'}]");
		}

		//아이디존재
		else {
			//아이디비번일치
			if (mvo.getM_pwd().equals(c_pwd)) {
				String alias = mvo.getM_alias();
				int grade = mvo.getG_no();
				request.getSession().setAttribute("login", "on");
				request.getSession().setAttribute("alias", alias);
				request.getSession().setAttribute("grade", grade);

				out.println("[{'result':'success'}]");
			}
			//아이디비번불일치
			else
				out.println("[{'result':'fail'}]");
		}
	}

	else if(login.equals("off")) {
		request.getSession().setAttribute("login", "off");
		session.invalidate();
		System.out.println("logoff");
	}
%>
